﻿@model string
<div class="current-location">
    <ul>
        <li class="left"><i class="glyphicon glyphicon-home"></i><a href="javascript:void(0)" onclick="location.href=location.href">管理菜单</a></li>
        <li class="right"><a href="javascript:void(0)" onclick="LoadData()" title="刷新"><span class="glyphicon glyphicon-refresh"></span></a></li>
    </ul>
</div>
<div class="main">
    <table border=0 cellpadding=0 cellspacing=0 class="tb-head form-inline form-group-sm">
        <tr>
            <td>
                <div class="btn-group btn-group-sm">
                    <button type="button" class="btn btn-default ui-selectInvert">反选</button>
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                        菜单<span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="javascript:void(0)" class="ui-dialog" data-custom-params="title:'添加顶部菜单',url:'@Url.ActionUrl("add")?parentId=0&level=1',width:'95%',height:'95%'">添加顶部菜单</a></li>
                        <li class="divider"></li>
                        <li><a href="javascript:void(0)" class="ui-updateMultiple" data-custom-params="url:'@Url.ActionUrl("UpdateList")',callBack:'LoadData'">更新</a></li>
                        <li class="divider"></li>
                        <li><a href="javascript:void(0)" class="ui-setField" data-custom-params="url:'@Url.ActionUrl("SetField")',setField:'isFinal',setValue:'1',limitFinal:'0',includeChildNode:'0',beforeExecute:'BeforeExecuting',callBack:'LoadData'">转为最终菜单</a></li>
                        <li><a href="javascript:void(0)" class="ui-setField" data-custom-params="url:'@Url.ActionUrl("SetField")',setField:'isFinal',setValue:'0',limitFinal:'1',beforeExecute:'BeforeExecuting',callBack:'LoadData'">转为非最终菜单</a></li>
                        <li class="divider"></li>
                        <li><a href="javascript:void(0)" class="ui-setField" data-custom-params="url:'@Url.ActionUrl("SetField")',setField:'state',setValue:'0',beforeExecute:'BeforeExecuting'">停用</a></li>
                        <li><a href="javascript:void(0)" class="ui-setField" data-custom-params="url:'@Url.ActionUrl("SetField")',setField:'state',setValue:'1',beforeExecute:'BeforeExecuting'">启用</a></li>
                        <li class="divider"></li>
                        <li><a href="javascript:void(0)" class="ui-setMultiple" data-custom-params="url:'@Url.ActionUrl("Transfer")',width:'600px',height:'90%'">转移</a></li>
                        @*<li class="divider"></li>
    <li><a href="javascript:void(0)" class="ui-deleteMultiple" data-custom-params="url:'@Url.ActionUrl("Delete")',beforeExecute:'BeforeDeleteExecuting',callBack:'LoadData',reverseExecute:true">删除</a></li>*@

                    </ul>
                </div>
            </td>
        </tr>
    </table>
    <table border=0 cellpadding=0 cellspacing=0 class="table table-bordered form-inline form-group-sm" id="tb_list">
        <thead>
            <tr>
                <td align="center" style="width:40px"><input type="checkbox" title="选择" class="ui-selectInvert" data-custom-params="isReverse:false"></td>
                <td align=left><span>名称/</span><span class="ui-folder-switch">展开</span></td>
                <td align="center">类型</td>
                <td align="center">系统菜单</td>
                <td align="center">启用</td>
                <td align="center">序号</td>
                <td align="center">添加子菜单</td>
                <td align="center">菜单项</td>
                <td align="center">操作</td>
            </tr>
        </thead>
        <tr class="item parent_{parentId}" id='item_{id}' data-id="{id}" data-parentId="{parentId}" data-isFinal="{isFinal}" data-isSys="{isSys}" data-SysNode="{SysNode}">
            <td align="center"><input type="checkbox" value="{id}" class="checked-item"></td>
            <td align="center" style="text-align:left">{space}<span class="node node_{isFinal}"></span><span>{name}</span></td>
            <td align="center"><span class="sp_level">{level}</span></td>
            <td align="center"><span class="sp_issys is-{isSys}"></span></td>
            <td align="center"><span class="sp_show is-{state}"></span></td>
            <td align="center"><input type="text" name="xuhao" id="xuhao" class="form-control ui-listXuhao" value='{xuhao}' data-table="pa_admin_menu" data-id="{id}" style="width:50px" maxlength="3" /></td>
            <td align="center">
                <button type="button" data-custom-params="title:'{name}-添加子菜单',url:'@Url.ActionUrl("Add")?parentId={id}&parentLevel={level}',width:'95%',height:'95%'" class="btn btn-sm btn-default add_chilld_{isFinal} ui-dialog">添加</button>
            </td>
            <td align="center">
                <button type="button" data-custom-params="title:'{name}-菜单项目管理',url:'@Url.ActionUrl("index", "AdminMenuItem")?menuId={id}',width:'95%',height:'95%'" class="btn btn-default btn-sm menu_item_{isFinal} ui-dialog">管理</button>
            </td>
            <td align="center">
                <input type="hidden" name="id" value="{id}" />
                <div class="btn-group btn-group-sm">
                    <button type="button" data-custom-params="title:'{name}-编辑',url:'@Url.ActionUrl("Edit")?id={id}&level={level}',width:'95%',height:'95%'" class="btn btn-default btn-sm ui-dialog">修改</button>
                    <button type="button" data-custom-params="url:'@Url.ActionUrl("Delete")',callBack:'LoadData',async:false" class="btn btn-default btn-sm ui-deleteSingle btn-delete-{isSys}">删除</button>
                </div>
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    function LoadData() {
        var jsonUrl = "@Url.ActionUrl("ListData")";
        $("#tb_list").TreeBind({ url: jsonUrl, callBack: "LoadedInit" });
    }

    function LoadedInit() {
        $(".add_chilld_1").attr("disabled", "disabled");
        $(".menu_item_0").attr("disabled", "disabled");
        //初始化界面

        var $sp_issys = $(".sp_issys");
        var $sp_level = $(".sp_level");
        $sp_level.each(function () {
            var $this = $(this);
            if ($this.html() == "1") {
                $this.html("顶部菜单");
            }
            else {
                $this.html("左侧菜单")
            }
        });
        $(".btn-delete-1").attr("disabled", "disabled");
    }
    LoadData();



    function BeforeExecuting(ids) {
        var arrIds = ids.split(",");
        for (i = 0; i < arrIds.length; i++) {
            var currentObj = $("#item_" + arrIds[i]);
            if (currentObj.attr("data-SysNode")!= "") {
                Alert("您选中的节点包含系统内置节点，不支持此操作！");
                return false;
            }
        }
        return true;
    }
</script>
